package sagroup.util;

import lime2.Launcher;
import lime2.LimeServer;
import lime2.LimeTemplate;
import lime2.Location;

public class Limes {

	public static LimeTemplate createHUTemplate(Object t) {
		return new LimeTemplate(Location.HERE, Location.UNSPECIFIED,
				Lights.creatTuple(t));
	}

	public static LimeTemplate createHHTemplate(Object t) {
		return new LimeTemplate(Location.HERE, Location.HERE, Lights.creatTuple(t));
	}

	public static void startServer(int port, int httpPort) {
		LimeServer server;
		server = LimeServer.getServer();
		if (!server.isBooted()) {
			// if the user did not choose any tuplespace factory then we use the
			// default tuplespace factory
			String tsfactory = "lights.dracots.TupleSpaceFactory";
	
			// starts server
			Launcher.launch("-start -port " + port + " -http " + httpPort
					+ " -tsfactory " + tsfactory);
			System.out.println("--- open http://localhost:" + httpPort
					+ "/ with your browser ---\n");
//			Launcher.launch("-start -http 8080 -tsfactory " + tsfactory);
//			System.out
//					.println("--- open http://localhost:8080/ with your browser ---\n");
	
			// server.boot();
		}
	}

}
